package com.ojoin.ojoin.eb_spider.service.impl;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.springframework.stereotype.Service;

import com.ojoin.ojoin.eb_spider.service.HttpResponseService;
import com.ojoin.trade.common.utils.CommonUtils;
@Service
public class HttpResponseServiceImpl implements HttpResponseService{

	@Override
	public boolean isLogin(HttpResponse httpResponse) {
        int num = StatusCode(httpResponse);
		if(num != 200){
			return false ;
		}else {
			return true ;
		}
	}

	@Override
	public int StatusCode(HttpResponse httpResponse) {
		return httpResponse.getStatusLine().getStatusCode();
	}

	/**
	 * 字符串形式
	 * 
	 */
	@Override
	public String getCookie(HttpResponse httpResponse) {
		boolean flag = isLogin(httpResponse);
		if(flag){
			 Header[] heads = httpResponse.getHeaders("Set-Cookie");
			 if(!CommonUtils.isEmpty(heads)){
				 for(Header head:heads){
					 head.getValue();
				 }
		}
		
		return null;
	}

	return null;
}
}
